{{template "admin/public/head.html" .}}
<section>
	<aside>
		{{template "admin/public/nav.html" .}}
	</aside>
	<style type="text/css">
		.mask .mask-content{height: 27vh}
		.img-1{height: 80px !important;width: 80px!important;}
		.gray{background: rgba(235,235,235,0.5);}
	</style>
	<article>
		<div class="top-title">
			<dl>
				<dt><h1>{{.title}}</h1></dt>
				<dd><form method="get"><input type="text" class="input" placeholder="请输入您需要搜索的订单号、姓名或手机号！" name="search"><input type="submit" value="搜索" class="button" /></form></dd>
			</dl>
		</div>
		<div class="nav1">
			<ul>
				<a href="{{.urlc}}"><li>全部订单</li></a>
				<a href="{{.urlc}}&status=1"><li>待付款</li></a>
				<a href="/admin/order/gbuy_index"><li class="no">待分享</li></a>
				<a href="{{.urlc}}&status=2"><li>待发货</li></a>
				<a href="{{.urlc}}&status=3"><li>待收货</li></a>
				<a href="{{.urlc}}&status=4"><li>待评价</li></a>
				<a href="{{.urlc}}&status=5"><li>已完成</li></a>
			</ul>
		</div>
		<div class="content">
			<div class="release">
				<dl>
					<dt><i class="iconfont">&#xe649;</i> <b>{{.title}}说明</b><br>
						下方是{{.title}}列表<br>
						<p> 如有特殊需要,在未付款的时候可以修改订单的价格</p>
					</dt>
					<dd>
						<a href="/admin/orders/excel?status={{.status}}">
							<button type="button" class="button">批量导出excel</button>
						</a>
					</dd>
				</dl>
			</div>

			<table class="table">
				<thead><th width="15%">用户</th><th width="30%">发货信息</th><th width="30%">订单信息</th><th width="15%">操作</th></thead>
				{{range $k,$v:=.info}}
				<tr id="{{.id}}" >
					<td class="center"><a href="/admin/member/content?id={{.uid}}" class="tz"><img src="{{.pathname}}" class="img-1"><br>{{.monicker}}</a></td>
					<td>
						姓名：{{$v.name}}<br>
						手机：{{$v.mobile}}<br>
						地址：{{$v.shen}} {{$v.shi}} {{$v.qu}} {{$v.address}}<br>
					</td>
					<td>
						订单号：<a href="/admin/order/content?id={{.id}}" class="tz">{{$v.ordernum}}</a><br>
						原价：&yen;{{$v.price}}<br>
						实际价格：<b style="color:#e54242">&yen;{{$v.money}}</b>{{if .rmoney}}(退款&yen;{{.rmoney}}实际&yen;{{.smoney}}){{end}}<br>
						{{if ne $v.tj "0.00"}}
						体积：{{$v.tj}}立方<br>
						{{end}}
						{{if ne $v.zl "0.00"}}
						重量：{{$v.zl}}千克<br>
						{{end}}
					</td>
					<td class="operation">
						{{if eq $v.status "1"}}
						<b style="color:#666">待付款</b>
						{{else if eq $v.status "2"}}
						<b style="color:red">待发货</b>
						{{else if eq $v.status "3"}}
						<b style="color:#009900">待收货</b>
						{{else if eq $v.status "4"}}
						<b style="color:#00ffff">待评价</b>
						{{else if eq $v.status "4"}}
						<b>已完成</b>
						{{end}}<br>

						{{if eq $v.status "1"}}
						<a class="editprice" data-id="{{$v.id}}" data-money="{{$v.money}}">修改价格</a><br>
						<a class="del" data-id="{{$v.id}}">取消订单</a><br>
						{{end}}
						<a href="/admin/order/content?id={{$v.id}}">详情</a><br>
						{{if eq $v.status "2"}}
						<a href="/admin/order/send?id={{$v.id}}">发货</a><br>
						{{end}}
						<a href="/admin/order/excel?id={{$v.id}}">导出excel</a><br>
						<a href="javascript: void(0)" data-id="{{$v.id}}" class="exportImgs">导出产品图片</a>
					</td>
				</tr>				
				<!-- <thead><th colspan="8">产品信息</th></thead> -->
				<!-- {{range $v.product}}
					<tr>
						<td class="center"><a href="/admin/product/content?id={{.pid}}" class="tz"><img src="{{.pathname}}" class="img-1"></a></td>
						<td>
							产品标题：<a href="/admin/product/content?id={{.pid}}" class="tz">{{.title}}</a><br>
							型号：{{.model}}<br>
							购买单价：&yen;{{.pprice}}/箱
						</td>
						<td>
							发货/购买数量：{{.sendnum}}/{{.num}}箱<br>
							{{if eq $.admin_gid "0"}}
							提货司机：{{if .monicker}}<a href="/admin/member/content?id={{.did}}" class="tz">{{.monicker}}</a>{{end}}
							{{end}}<br>
							体积：{{.tj}}<br>
							重量：{{.weight}}<br>
						</td>
						<td class="operation">
							{{if eq $.admin_gid "0"}}
							状态：{{if eq .status "1"}}待备货{{else if eq .status "2"}}待取货{{else if eq .status "3"}}待发货{{else if eq .status "4"}}已发货{{end}}<br>
							{{if .monicker}}
							已分配司机<br>
							{{else}}
							<a class="tz driver" data-id="{{.id}}" id="{{.id}}">分配司机</a><br>
							{{end}}
							{{end}}
							{{if eq .status "3" "4" "5"}}
							{{if ne .num .sendnum}}
							{{if eq .return "0"}}
							<a class="tz return" data-id="{{.id}}" data-oid="{{$v.id}}" data-rprice="{{.rprice}}">退款(&yen;{{.rprice}})</a><br>
							{{else}}
							已退款<br>
							{{end}}
							{{end}}
							{{end}}
						</td>
					</tr>
				{{end}} -->
				{{end}}
				{{if ne .paginator.totalpages 1}}
					<tr>
						<td  colspan="5">
							<div class="paging">
								{{if ne .paginator.currpage 1}}
								<a href="{{$.url}}page={{.paginator.firstpage}}">首页</a>
								<a href="{{$.url}}page={{.paginator.prevpage}}">&lt;&lt;</a>
								{{else}}
								<a class="disable">首页</a>
								<a class="disable">&lt;&lt;</a>
								{{end}}
								{{range $index,$page := .paginator.pages}}
								{{if eq $.paginator.currpage $page}} 
								<a class="no">{{$page}}</a>
								{{else}}
								<a href="{{$.url}}page={{$page}}">{{$page}}</a>
								{{end}}
								{{end}}
								{{if eq .paginator.currpage .paginator.totalpages}}
								<a class="disable">&gt;&gt;</a>
								<a class="disable">尾页</a>
								{{else}}
								<a href="{{$.url}}page={{.paginator.nextpage}}">&gt;&gt;</a>
								<a href="{{$.url}}page={{.paginator.totalpages}}">尾页</a>
								{{end}}
							</div>
						</td>
					</tr>
				{{end}}
			</table>


		</div>
	<div class="mask">
		<div class="mask-content">
			<form id="parameter">
				<table class="table1">
					<thead><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th></thead>
					<tr>
						<td class="genre" colspan="2">原价</td>
						<td colspan="6">
							<input type="text" class="input95" placeholder="请输入要修改的价格！" readonly="" id="money">
						</td>
					</tr>
					<tr>
						<td class="genre" colspan="2">价格</td>
						<td colspan="6">
							<input type="text" class="input95" placeholder="请输入要修改的价格！" name="price">
						</td>
					</tr>
				</table>
				<input type="hidden" name="id">
			</form>
			<p id="tip"></p>
			<div class="mask-form">
				<dl>
					<dt>
						<button id="qr">保存</button>
						<button id="cancle">取消</button>
					</dt>
					<dd>
					</dd>
				</dl>
			</div>
		</div>
	</div>
	<style type="text/css">
		.maskdriver{position: fixed;top: 0;left: 0;background-color: rgba(0,0,0,0.3);z-index: 10000;width: 100vw;height: 100vh;display: none;}
		.maskdriver ul{height: 40vh;width: 150px;position: absolute;top: 30vh;left: calc(50% - 75px);z-index: 10001;background: #fff;
			overflow-y: scroll;padding: 15px}
		.maskdriver ul li{width: 100%;overflow:hidden;padding: 5px 0;border-bottom: 1px solid #eee}
		.maskdriver ul li img{width: 40px;height: 40px;float: left;}
		.maskdriver ul li div{width:calc(100% - 40px)height:40px;float: left;}
		.maskdriver ul li div p{line-height: 20px;font-size: 14px;padding-left: 10px}
		.maskdriver ul li div p:nth-of-type(2){font-size: 12px;color: #666}
	</style>
	<div class="maskdriver">
		<ul>
			{{range .driver}}
			<li class="driverlist" data-id="{{.id}}" data-monicker="{{.monicker}}">
				<img src="{{.pathname}}">
				<div>
					<p>{{.monicker}}</p>
					<p>{{.name}}</p>
				</div>
			</li>
			{{end}}
		</ul>
	</div>
	</article>
</section>
<footer></footer>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/jquery.jedate.min.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/toast.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/uppic.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/xcConfirm.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/app.js"></script>
<script>
	var id;
	$('.driver').click(function(){
		id=$(this).attr('data-id')
		var scrolltop=$(window).scrollTop()-20
		var offset=$(this).offset()
		var height=$('.maskdriver ul').height()
		var wheight=$(window).height()
		$('.maskdriver ul').css('left',offset.left)
		var top=offset.top-scrolltop
		if(top+height>wheight){
			top=top-height-40
		}
		$('.maskdriver ul').css('top',top)
		$('.maskdriver').show()
	})
	$('.maskdriver').click(function(){
		$(this).hide()
	})
	$('.driverlist').click(function(){
		var did=$(this).attr('data-id')
		var monicker=$(this).attr('data-monicker')
		$.ajax({
			url:'/admin/order/driver',
			data:{id:id,did:did},
			success:function(res){
				if(res==1){
					/*$('#'+id).attr('class','tz')
					$('#'+id).attr('href','/admin/member/content?id='+did)
					$('#'+id).html(monicker)*/
					history.go(0)
				}else{
					wxc.xcConfirm("操作失败,请重试","error");
				}
			}
		})
	})
	$('.editprice').click(function(){
		var id=$(this).attr('data-id')
		var money=$(this).attr('data-money')
		$('#money').val(money)
		$('input[name="id"]').val(id)
		$('.mask').css('display','block')
	})
	$('#cancle').click(function(){
		$('#money').val('')
		$('input[name="id"]').val('')
		$('input[name="price"]').val('')
		$('.mask').css('display','none')
	})
	$('#qr').click(function(){
		var form=$('#parameter').serialize()
		$.ajax({
			url:'/admin/order/edit',
			data:form,
			success:function(res){
				if(res==1){
					history.go(0)
				}else{
					wxc.xcConfirm("操作失败,请重试","error");
				}
			}
		})
	})

    $('.del').click(function(){
		var id=$(this).attr('data-id');
		wxc.xcConfirm("您确定要取消这笔订单吗?","confirm",{onOk:function(){
			$.ajax({
				url:'/admin/del',
				data:{table:'mt_order',id:id},
				type:'get',
				success:function(res) {
					if(res==1){
						showMessage('取消成功');
						$('#'+id).css('display','none');
					}else{
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})	
		}});
	})
	$('.return').click(function(){
		var id=$(this).attr('data-id');
		var oid=$(this).attr('data-oid');
		var rprice=$(this).attr('data-rprice');
		wxc.xcConfirm("您确定要退款吗?","confirm",{onOk:function(){
			$.ajax({
				url:'/admin/order/return_outofstock',
				data:{id:id,oid:oid,rprice:rprice},
				success:function(res) {
					if(res==1){
						history.go(0)
					}else{
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})
		}});
	})
	$('.exportImgs').click(function () {
		var id = $(this).attr('data-id')
		wxc.xcConfirm("您确定要导出图片吗", "confirm", {onOk: function () {
			$.ajax({
				url: '/admin/order/export_imgs',
				data: {id: id},
				success: function (res) {
					if (res.status == 1) {
						$('body').toast({
                            position:'fixed',
                            animateIn:'fadeIn',
                            animateOut:'fadeOut',
                            content:'操作成功,准备接收文件!',
                            duration:'500',
                            isCenter:true,
                        });
                        location = location.origin+'/'+res.filePath
					} else {
						var msg = res.msg || '文件处理错误,请重试!'
						wxc.xcConfirm(msg, 'error')
					}
				}
			})
		}})
	})
</script>
</body>
</html>
